package com.huluobo.a2107mvpimdemo.splash.view;

import android.content.Intent;
import android.os.Handler;

import com.huluobo.a2107mvpimdemo.demo.MyView;
import com.huluobo.a2107mvpimdemo.main.MainActivity;
import com.huluobo.a2107mvpimdemo.R;
import com.huluobo.a2107mvpimdemo.base.BaseActivity;
import com.huluobo.a2107mvpimdemo.login.view.LoginActivity;
import com.huluobo.a2107mvpimdemo.splash.presenter.SplashContract;
import com.huluobo.a2107mvpimdemo.splash.presenter.SplashPresenter;
import com.hyphenate.chat.EMClient;

public class SplashActivity extends BaseActivity<SplashContract.View, SplashPresenter> implements SplashContract.View {
    private MyView myView;

    @Override
    protected void initData() {
        presenter = new SplashPresenter();
    }

    @Override
    protected void initView() {
        myView = findViewById(R.id.splash_myView);
        myView.start(1);
        myView.setOnAnimEndListener(new MyView.OnAnimEndListener() {
            @Override
            public void onAnimEnd() {
                presenter.checkIsLoggedInBefore();
            }
        });
    }

    @Override
    protected int bindLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    public void isLoggedIn() {
        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
        startActivity(intent);
    }

    @Override
    public void isNotLoggedIn() {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
    }
}